#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
bool flag;
char ph[20];
struct Node{
    //以该点结尾的单词数
    int c;
    int f;
    Node* Next[2];
    Node(){
        c=0;
        f=0;
        for(int i=0;i<2;i++){
            Next[i]=NULL;
        }
    }
};
void insert(Node* &rt,char* s){
    int l=strlen(s);
    int val;
    Node* p=rt;
    for(int i=0;i<l;i++){
        val=s[i]-'0';
        if(p->Next[val]==NULL){
            p->Next[val]=new Node();
        }
        p=p->Next[val];
        if(p->f){
            flag=true;
        }
    }
    p->f=1;
}
void clear(Node* root){
    if(root==NULL){
        return;
    }
    for(int i=0;i<2;i++){
        clear(root->Next[i]);
    }
    delete(root);
}
int main(void){
    int c=1;
    Node* root=new Node();
    while(~scanf("%s",ph)){
        if(ph[0]!='9'){
            insert(root,ph);
        }
        else{
            if(flag){
                printf("Set %d is not immediately decodable\n",c++);
            }
            else{
                printf("Set %d is immediately decodable\n",c++);
            }
            flag=false;
            clear(root);
            root=new Node();
        }
    }
    return 0;
}
